package hot100;



import com.链表.练习题.ListNode;

public class g1_相交链表 {
    public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
        ListNode p1 = headA;
        ListNode p2 = headB;
        while (true) {
            if(p1 == p2){
                return p1;
            }
            if(p1 == null){
                p1 = headB;
            }else {
                p1 = p1.next;
            }
            if(p2 == null){
                p2 = headA;
            }else {
                p2 = p2.next;
            }
        }
    }
}
